package com.ctshk.sapp.order.custom.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.exception.BusinessException;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.order.custom.dto.order.CustomOrderTouristVisaDetailDTO;
import com.ctshk.rpc.order.custom.dto.tourist.CustomOrderTouristVisaListDTO;
import com.ctshk.rpc.order.custom.req.order.CustomOrderTouristVisaDetailReq;
import com.ctshk.rpc.order.custom.req.order.CustomOrderTouristVisaSubmitBatchReq;
import com.ctshk.rpc.order.custom.req.order.CustomOrderTouristVisaSupplementBatchReq;
import com.ctshk.rpc.order.custom.req.tourist.CustomOrderTouristIdReq;
import com.ctshk.rpc.order.custom.req.tourist.CustomOrderTouristVisaListReq;
import com.ctshk.rpc.order.custom.service.ICustomizedOrderTouristVisaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 游客签证记录 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-02-22
 */
@Api(value="游客签证", tags="游客签证")
@RestController
@Slf4j
@RequestMapping("/customized-order-tourist-visa")
public class CustomizedOrderTouristVisaController extends BaseController {

    @DubboReference
    private ICustomizedOrderTouristVisaService orderTouristVisaService;


    @ApiOperation(value = "列表", notes = "簽證列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "簽證列表", operDesc = "簽證列表")
    @PostMapping("/list")
    public Result<PageResponse<CustomOrderTouristVisaListDTO>> list(@RequestBody @Valid CustomOrderTouristVisaListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        try {
            return Result.success(orderTouristVisaService.list(req));
        }catch (BusinessException e){
            return Result.failed(e);
        }
    }

    @ApiOperation(value = "收齊證件提交後台", notes = "收齊證件提交後台（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "簽證管理-收齊證件提交後台", operDesc = "簽證管理-收齊證件提交後台")
    @PostMapping("/submit/batch")
    public Result submitBatch(@RequestBody @Valid CustomOrderTouristVisaSubmitBatchReq req) {
        try {
            req.setUserId(getCurrentUser(getRequest()).getId());
            return orderTouristVisaService.submitBatch(req);
        }catch (BusinessException e){
            return Result.failed(e);
        }
    }

    @ApiOperation(value = "提交後補資料", notes = "提交後補資料（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "提交後補資料", operDesc = "提交後補資料")
    @PostMapping("/supplement/batch")
    public Result supplementBatch(@RequestBody @Valid CustomOrderTouristVisaSupplementBatchReq req) {
        try {
            req.setUserId(getCurrentUser(getRequest()).getId());
            return orderTouristVisaService.supplementBatch(req);
        }catch (BusinessException e){
            return Result.failed(e);
        }
    }

    @ApiOperation(value = "簽證详情", notes = "簽證详情（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "簽證管理-查看", operDesc = "簽證管理-查看")
    @PostMapping("/detail")
    public Result<CustomOrderTouristVisaDetailDTO> detail(@RequestBody @Valid CustomOrderTouristVisaDetailReq req) {
        try {
            return orderTouristVisaService.detail(req);
        }catch (BusinessException e){
            return Result.failed(e);
        }
    }

}
